package com.gemme.gemme.shequ;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.bumptech.glide.Glide;
import com.gemme.gemme.R;
import com.gemme.gemme.fragment.BaseLazyFragment;
import com.gemme.gemme.home.BrandBean;
import com.gemme.gemme.home.ProductBean;
import com.gemme.gemme.manager.DataManager;
import com.gemme.gemme.view.ProductChildView;
import com.gemme.gemme.view.StaggeredDividerItemDecoration;
import com.yanzhenjie.recyclerview.SwipeRecyclerView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;


/**
 * Created by sp on 2019/7/18.
 * 首页
 */
public class ProductNewFragment extends BaseLazyFragment  {

    View inflate;
    Context mContext;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        inflate = inflater.inflate(R.layout.fragment_product_new, container, false);

        mContext = ProductNewFragment.this.getContext();

        initView(inflate);
        return inflate;
    }


    private void initView(View inflate) {
        getData();
    }

    private void getData() {
        String url_chanpin = DataManager.BaseUrl_panghu + "mall/shopproductcategory/shopProductAll";
        HashMap<String, String> headMap = new HashMap<>();
        headMap.put(DataManager.AuthorizationKey,"Bearer ca19c118-e9f2-46a4-b03f-9950cb1a75dc");
        DataManager.toServer(mContext, url_chanpin, true, "", headMap, new DataManager.GeResponse() {
            @Override
            public void onResponse(String response) {

                try {
                    ProductBean productBean = JSON.parseObject(response, ProductBean.class);
                    List<ProductBean.DataBean> data = productBean.getData();
                    /*if(data != null){
                        ProductAdapter brandAdapter =  new ProductAdapter(data);
                        mRecyclerView.setAdapter(brandAdapter);
                        System.out.println();
                    }*/

                }catch (Exception e){

                }
            }
        });
    }





    @Override
    public void onLazyLoad() {

        //yc

//        getData();
    }









}
